package hz.mobileproject.pda.utils;

import android.util.Log;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.SPUtils;

import hz.mobileproject.pda.ui.activity.TestSettingActivity;

/**
 * Created by hasee on 2018/1/10.
 */

public class SettingFileUtil {

    public static void init(){
        //只初始化一次
        if (SPUtils.getInstance("setting").getBoolean(TestSettingActivity.NOW_VERSION+"isFirstInit", true)){
            SPUtils.getInstance("setting").put(TestSettingActivity.NOW_VERSION+"isFirstInit", false);
            //手持机打包默认IP和端口
            SPUtils.getInstance("setting").put("base_url"
                    , "http://" + TestSettingActivity.NOW_IP + ":" + TestSettingActivity.PORT);
            SPUtils.getInstance("setting").put("base_ip", TestSettingActivity.NOW_IP);
            SPUtils.getInstance("setting").put("version", TestSettingActivity.NOW_VERSION);   //四监版本为2.6.1
            SPUtils.getInstance("setting").put("is_neimeng", "0");
            LogUtils.e("请求接口的ip" + SPUtils.getInstance("setting").getString("base_ip"));
        }
    }

    public static String getProperties(String proName){
        String pro_value = SPUtils.getInstance("setting").getString(proName);
        Log.i("SettingFileUtil", "setting get " + proName + " = " + pro_value);
        return pro_value;
    }

    public static void setProperties(String proName, String proValue) {
        SPUtils.getInstance("setting").put(proName, proValue);
        Log.i("SettingFileUtil", "setting set " + proName + " = " + proValue);
    }
}
